using System;
using System.Data;
using System.Data.SqlClient;

using PHSRAG.Insight21.BusinessObjects;
using ICachePolicy = PHSRAG.Insight21.Policy.ICachePolicy;

namespace PHSRAG.Insight21.ClinicalTrials
{
   /// <summary>
   /// The BudgetVisit class is the facade over a single Budget Visit
   /// </summary>
   public class BudgetVisit : BusinessObject
   {

      #region Constants
      private const string BudgetVisitKey = "BudgetVisit_F52323F3-AE23-4135-BE10-4006E4B47755";
      private const string TableName = "BudgetVisit";
      #endregion

      #region Instance Variables
      private DataRow dataRow;
      #endregion

      #region Public Properties
      /// <summary>
      /// Unique Id for this Budget Visit
      /// </summary>
      public int Id
      {
         get
         {
            return (int)dataRow["Id"]; 
         }
      }

      /// <summary>
      /// Budget relate id
      /// </summary>
      public int BudgetId
      {
         get
         {
            return (int)dataRow["ClinicalTrialBudgetId"];
         }
         set
         {
            dataRow["ClinicalTrialBudgetId"] = value;
         }
      }

      /// <summary>
      /// Visit number
      /// </summary>
      public int VisitNumber
      {
         get
         {
            return (int)dataRow["VisitNumber"];
         }
         set
         {
            dataRow["VisitNumber"] = value;
         }
      }

      /// <summary>
      /// Visit Description
      /// </summary>
      public string VisitDescription
      {
         get
         {
            return dataRow["VisitDescription"].ToString( );
         }
         set
         {
            dataRow["VisitDescription"] = value;
         }
      }
      #endregion

      #region Constructor
      /// <summary>
      /// Initialize the base class with the specified cache policy and sets the dataRow member.
      /// </summary>
      public BudgetVisit( ICachePolicy cachePolicy, DataRow row ) : base ( cachePolicy )
      {
         dataRow = row;
      }
      #endregion

      #region Base Methods
      /// <summary>
      /// Cache this instance using the prevalent cache policy.
      /// </summary>
      public override void Cache( )
      {
         CachePolicy.Cache( BudgetVisitKey, this );
      }

      /// <summary>
      /// Remove this instance from the cache using the prevalent cache policy.
      /// </summary>
      public override void UnCache( )
      {
         CachePolicy.UnCache( BudgetVisitKey );
      }

      /// <summary>
      /// Load method is not used
      /// </summary>
      /// <param name="connectionString"></param>
      /// <param name="args"></param>
      public override void Load( string connectionString, params object[] args )
      {
         throw new Exception("BudgetVisit is not directly loadable");
      }
      #endregion

   }// END CLASS DEFINITION BudgetVisit
}